#CC = gcc
CC = /home/mengbo/code/test/openwrt-sdk/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_musl/bin/aarch64-openwrt-linux-musl-gcc
#CC = g++
#CXX = /home/czp/word/toolchain/atk-dlrv1126-toolchain/usr/bin/arm-linux-gnueabihf-g++
CCFLAGS = -g -lrt -lssl -lcrypto
CXXFLAGS = -O2 -g -Wall -fmessage-length=0 -std=c++11 -lssl -lcrypto

SOURCES = $(wildcard ../main/*.c ../src/*.c)
#OBJS = SmartProbe.o ctrl.o log.o iniparser.o dictionary.o common.o mqttClient.o
OBJS = $(SOURCES:.c=.o)

HEADER_PATH = -I../include -I../include/json
LIB_PATH = -L../lib
SRC_PATH = ../main
LIB_SET = -Wl,-rpath="../lib"

#LIBS = $(LIB_PATH) $(LIB_SET) -lpaho-mqtt3as -lMQTT_AGENT -lcjson -lzlog -lsqlite3
LIBS = $(LIB_PATH) $(LIB_SET) -lpaho-mqtt3as -lcjson -lzlog -lsqlite3 -lfile_encrypt -lpthread -lcurl -lm

ifeq ($(OS), Windows_NT)
	TARGET = MQTT_Demo.exe
else 
	TARGET = SmartProbe
endif

$(TARGET):	$(OBJS)
	echo "test"
	#cd ../build && cmake . && make
	#make && cd ..
	#make -C ../build
	$(CC) $(CCFLAGS) -o $(TARGET) $(OBJS) $(LIBS)

#%.o: $(SRC_PATH)/%.c
%.o: %.c
	$(CC) $(CCFLAGS) -c  -o $@ $< $(HEADER_PATH) #-std=c99 
	
all:	
	$(TARGET)

clean:
	#make clean -C ../build
	rm -f $(OBJS) $(TARGET)
